#ifndef __CAMERA_H__
#define __CAMERA_H__

#include "Point3D.h"
#include "Common.h"
#include "OrthonomalBasis.h"

namespace Engine
{
	class Camera
	{
	public:

		friend class World;
		float m_fov;
		float m_aspectRatio;
		float m_viewPlaneDistance;

		Point3D eye;
		Camera()
		{
			eye = Point3D(0, 0, 1);

			m_orthonomalVectors.w = Point3D(0, 0, -4);
			m_orthonomalVectors.up = Point3D(0, 1, 0);
			//v = w.cr
			//ComputeUvw();
		}

		void MoveCamera(float& p_delta)
		{

		}

		Camera(Point3D& p_eye, Point3D& p_lookat)
		{
			eye = p_eye;
			lookAt = p_lookat;
			ComputeUvw();
		}

		Camera(Point3D p_eye, Point3D p_lookat, float p_fov, float p_aspectRatio, float p_viewPlaneDistance)
		{
			m_fov = p_fov;
			m_aspectRatio = p_aspectRatio;
			m_viewPlaneDistance = p_viewPlaneDistance;
			eye = p_eye;
			lookAt = p_lookat;
			ComputeUvw();
		}

		void ComputeUvw()
		{
			m_orthonomalVectors.ProduceOrthonomalBasis(lookAt - eye);
		}

		Point3D GetCameraDirection(Point3D p_otherCamera)
		{
			Point3D output(p_otherCamera.dot(m_orthonomalVectors.up), p_otherCamera.dot(m_orthonomalVectors.v), p_otherCamera.z);
			return output;
			//return p_otherCamera;
		}

		~Camera()
		{}

	protected:
		
		//look at position
		Point3D lookAt;
		//Up, x axis and direction
		OrthonomalBasis m_orthonomalVectors;
		//Delta time
		float exposureTime;
		float viewPlaneDistance;
	};
}
	

#endif // !__CAMERA_H__
